<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>
<form name="form1" id="form1" action="${systemctx}/sample/saveSample.web" method="post">
	<div class="pageMain">
		<div class="pageTitle"><%=MessageResourcesUtils.getMessage(request, "systemmanage.storemanagement.title") %><span></span>
		<%=MessageResourcesUtils.getMessage(request, "dailyoperation.messageSwitchmanage.manage.title") %><span></span>
		<%=MessageResourcesUtils.getMessage(request, "dailyoperation.messageSwitchmanage.title") %>
		</div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i>*</i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.storecode") %></label>
						<span>
							<input type="text" id="storecode" name="storecode" value="" class="validate[required,maxSize[50]]"/>
							<input type="hidden" id="storeid" name="storeid"  >
						</span>
					</li>
					<li>
						<i></i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.storename") %></label>
						<span><input type="text" id="storename" name="storename" value="" readonly="readonly" /></span>
					</li>
					
				</ul>
			</div>	
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butQuery" name="butQuery" value="<%=MessageResourcesUtils.getMessage(request, "common.button.query") %>" />
			<!-- 
			<input type="button" class="btn btn-default" id="butAdd" name="butAdd" value="<%=MessageResourcesUtils.getMessage(request, "common.button.add") %>" />
			 -->
			<input type="button" class="btn btn-default" id="butStart" name="butStart" value="<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.button.start") %>" />
			<input type="button" class="btn btn-default" id="butStop" name="butStop" value="<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.button.stop") %>" />
		</div>
		<table width="100%">
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
<script type="text/javascript">
$(document).ready(function(){	
	$('#datagrid').issdatagrid({
		formid : 'form1',
		title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.messageSwitchmanage.title.list")%>',
		width : 'auto',
		nowrap : true,
		autoRowHeight : false,
		singleSelect : false,
		striped : true,
		url : '${systemctx}/dailyoperation/storemessageSwitch/queryMessageSwitchmanageListInfoDataGrid.json',
		sortName: 'id',
		sortOrder: 'desc',
		remoteSort : true,
		idField : 'id',
		pagination : true,
		rownumbers : true,
		showFooter : true,
		queryParams:$('#form1').serializeObject(),
		columns : [[ 
			 {field:'ck', checkbox:true},
			 {field:'id',title : '操作',width:90,align:'center',
				 formatter:function(val, row,index) {
					return '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="detailSet('+ row.id +')">设置</a> ';
				 }
			 },
             {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.messageSwitchmanage.column.storecode")%>',field : 'number',sortable : true,align : 'left',width:190,
				 formatter: function(value,row,index){
					return "<a href=\"javascript:void(0);\" onclick=\"detailView('"+row.id+"')\">"+value+"</a>";
				}
         	 }, 
             {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.messageSwitchmanage.column.storename")%>',field : 'name',sortable : true,align : 'left',width:220},	             
             {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.corporate")%>',field : 'corporate',sortable : true,align : 'left',width:120},
             {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.quality")%>',field : 'quality',sortable : true,align : 'left',width:80}, 
           	 {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.population")%>',field : 'population',sortable : true,align : 'left',width:80}, 
           	 {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.industry")%>',field : 'industry',sortable : true,align : 'left',width:120} 
           ]],
		onLoadSuccess : function(data) {

		}
	});
	
	$("#storecode").issNewMagnifier({
		title: '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databasebinding.storemagnifiertitle") %>',
		url: '${systemctx}/publicMagnifier/publicMagnifier.json',
		sortName : 'modifytime',
		sortOrder : 'desc',
		linkName: 'number',
		callSqlKey: 'queryStoreMagnifierSql',
		changeIgnore: ['storecode'],
		columns: [[
				{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.number") %>', field:'number', width:200, sortable:true, align: 'left', formel:'storecode'},
				{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.name") %>', field:'name', width:220, sortable:true, align: 'left', formel:'storename'},
				{field:'id',hidden:true,formel:'storeid'}
		]],
		onBeforeOpen:function(p){
	      var queryParams = {
	    		  querystore: '%' + $("#storecode").val() + '%',
	    		  statusid: <%=SysConstant.RecordStatus.VALID %>,
	    		  state : <%=SysConstant.CommonApproveStatus.OK %>
	      };
	      return queryParams;
	    }
	});
	
	$('#butQuery').click(function(){
		var exp = $('#form1').validationEngine('validate');
		if(exp == true){
			var id = $('#id').val();
			if(id ==''){
				alert('<%=MessageResourcesUtils.getMessage(request, "alertinfo.servicemanage.alert1") %>')
			}else{
				$('#datagrid').datagrid('load',$('#form1').serializeObject());
			}
		}
	});
	$('#butAdd').click(function(){
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/dailyoperation/storemessageSwitch/toAddMessageSwitchmanage.web"
		});
	});	
	
	$('#butStart').click(function(){
		var data=$('#datagrid').datagrid('getChecked');
		if(data!=null && data.length>0 && data.length != 0){
			var ids="";
			for(var i=0;i<data.length;i++){
				ids=data[i].id+";"+ids;
			}
			if (ids != '') {
				ids = ids.substring(0,ids.length-1);
			}
			if(confirm('<%=MessageResourcesUtils.getMessage(request,"dailyoperation.storechargemanage.alert.confirmstart")%>')){
				// 显示进度条
				showSending();
				$.ajax({
					type: 'POST',
				    url: '${systemctx}/dailyoperation/storemessageSwitch/batchStartInfo.json?status=1&ids='+ids,
				    dataType: 'json',
				    success: function(data) {
				    	//关闭执行...
						closeSending();
				    	if(data.messagetype == 1){
				    		alert(data.message);
				    		$('#datagrid').datagrid('reload',$('#form1').serializeObject());
							$('#datagrid').datagrid('clearSelections');
				    	}else {
				    		alert(data.message);
				    		return;
				    	}
				    }
				});
			}
		}else{
			alert('<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.alert.warning")%>');
			return;
		}
	});
	$('#butStop').click(function(){
		var data=$('#datagrid').datagrid('getChecked');
		if(data!=null && data.length>0 && data.length != 0){
			var ids="";
			for(var i=0;i<data.length;i++){
				ids=data[i].id+";"+ids;
			}
			if (ids != '') {
				ids = ids.substring(0,ids.length-1);
			}
			if(confirm('<%=MessageResourcesUtils.getMessage(request,"dailyoperation.storechargemanage.alert.confirmstop")%>')){
				// 显示进度条
				showSending();
				$.ajax({
					type: 'POST',
				    url: '${systemctx}/dailyoperation/storemessageSwitch/batchStopInfo.json?status=2&ids='+ids,
				    dataType: 'json',
				    success: function(data) {
				    	//关闭执行...
						closeSending();
				    	if(data.messagetype == 1){
				    		alert(data.message);
				    		$('#datagrid').datagrid('reload',$('#form1').serializeObject());
							$('#datagrid').datagrid('clearSelections');
				    	}else {
				    		alert(data.message);
				    		return;
				    	}
				    }
				});
			}
		}else{
			alert('<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.alert.warning")%>');
			return;
		}
	});	
});
function detailSet(storeid){
	$(this).isswindow({
		title : '<%=MessageResourcesUtils.getMessage(request, "servicemessage.services.ordermessage.view.title") %>',
		noheader : true,
		url : '${systemctx}/dailyoperation/storemessageSwitch/messageSwitchdetailmanageList.web?storeid='+storeid
	});
}
function detailView(storeid){
	$(this).isswindow({
		title : '<%=MessageResourcesUtils.getMessage(request, "servicemessage.services.ordermessage.view.title") %>',
		noheader : true,
		url : '${systemctx}/dailyoperation/storemessageSwitch/messageSwitchmanageView.web?storeid='+storeid
	});
}
</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>